<?php

class IframeController extends ProjectController
{
	public $layout = "//layouts/blank";
	public function actionView() { 
		
		$id = Yii::app()->request->getParam('pid',null);
		$project = Projects::model()->findByPk(outBin($id));
		if(empty($project)){
			jsonOut(array('error'=>true,'message'=>'Project not found'));
		}else{
			$structure = 'projects/'.outStr(currentUser(true)->id)."/".$project->name;
			// $dir = $this->find_all_files($structure);
			
			jsonOut(array(
				'error'=>false,
				'data'=>$project
			));
		}
		
		
	} 
	public function find_all_files($dir) 
	{ 
		$root = scandir($dir); 
		foreach($root as $value) 
		{ 
			if($value === '.' || $value === '..') {continue;} 
			if(is_file("$dir/$value")) {$result[]="$value";continue;} 
			foreach($this->find_all_files("$dir/$value") as $value) 
			{ 
				$result[]=$value; 
			} 
		} 
		return $result; 
	} 
		
}